<!DOCTYPE html>
<html>
<head>
  <title>微信验证码登录</title>
  <meta charset="utf-8">
</head>
<body>
<div id="weixin"></div>
<script
    src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js">
</script>


<script>
  var obj = new WxLogin(
      {
        id: "weixin",
        appid: "wx90c014a4624eaf04",
        scope: "snsapi_login",
        response_type:"code",
        redirect_uri: "http%3A%2F%2Fecmp.elviniot.net"
      });



  // 轮询检查用户是否已经扫码
  setInterval(function() {
    $.get("http://192.168.11.101:8006/platform/wechat/checkScan", function(result) {
      console.log("#####################")
      console.log(result)
      console.log("#####################")
      if (result.code == 0) {
        alert("请先扫码登录");
      } else if (result.code == 1) {
        // 用户已经扫码，跳转到回调页面
        window.location.href = "http://192.168.11.101:8006/platform/wechat/callback?code=" + result.data.code + "&state=" + result.data.state;
      }
    });
  }, 10000);
  
</script>
</body>
</html>
